<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateGoodsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goods', function (Blueprint $table) {
            $table->id();
            $table->string('goods_sn',100)->default('')->comment('商品编号');
            $table->string('name',200)->default('')->comment('商品名称');
            $table->integer('category_id')->nullable()->default(0)->comment('商品所属类目ID');
            $table->integer('brand_id')->nullable()->default(0)->comment('商品所属品牌ID');
            $table->string('gallery',1000)->nullable()->default('')->comment('商品宣传图片列表，采用JSON数组格式');
            $table->string('keywords',255)->nullable()->default('')->comment('商品关键字，采用逗号间隔');
            $table->string('brief',1000)->nullable()->default('')->comment('商品简介');
            $table->tinyInteger('is_on_sale')->nullable()->default(1)->comment('是否上架');
            $table->smallInteger('sort_order')->nullable()->default(1)->comment('商品排序');
            $table->string('pic_url',1000)->nullable()->default('')->comment('商品页面商品图片');
            $table->string('share_url',1000)->nullable()->default('')->comment('商品分享海报');
            $table->tinyInteger('is_new')->nullable()->default(0)->comment('是否新品首发，如果设置则可以在新品首发页面展示');
            $table->tinyInteger('is_hot')->nullable()->default(0)->comment('是否人气推荐，如果设置则可以在人气推荐页面展示');
            $table->string('unit',50)->nullable()->default('件')->comment('商品单位，例如件、盒');
            $table->decimal('counter_price',10,2)->nullable()->default(0.00)->comment('专柜价格');
            $table->decimal('retail_price',10,2)->nullable()->default(0.00)->comment('零售价格');
            $table->text('detail')->nullable()->default('')->comment('商品详细介绍，是富文本格式');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('goods');
    }
}
